package com.ctgu.j08.controller;

import com.ctgu.j08.service.AllocateService;
import com.ctgu.j08.vo.Allocate;
import com.ctgu.j08.vo.BuyList;
import com.ctgu.j08.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.xmlbeans.impl.xb.xsdschema.All;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @author: Saiya Wang
 * @date: 2021/6/2 17:09
 */
@Api
@Controller
@RequestMapping("/alloc")
public class AllocateController {
    @Autowired
    private AllocateService allocateService;

    @PostMapping("/add")
    @ApiOperation("添加分发信息")
    @ResponseBody
    public Result addAllocate(@RequestBody Allocate allocate){
        System.out.println("添加的设备"+allocate);
        return allocateService.addAllocate(allocate);
    }

    @PutMapping("/edit")
    @ApiOperation("修改分发信息")
    @ResponseBody
    public Result editBuyList(@RequestBody Allocate allocate)
    {
        return allocateService.editAllocate(allocate);
    }

    @GetMapping("/getAll")
    @ApiOperation("获取全部分发信息")
    @ResponseBody
    public Result getAllAllocateInfo()
    {
        return allocateService.getAllAllocateInfo();
    }

    @DeleteMapping("/del/{aId}")
    @ApiOperation("删除分发记录")
    @ResponseBody
    public Result delAllocate(@PathVariable("aId") Integer aId)
    {
        return allocateService.delAllocate(aId);
    }

}
